﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:Coding4Fun.Toolkit.Controls">

    <ControlTemplate x:Key="DisabledChatBubbleTextBoxTemplate" TargetType="TextBox">
		<ContentControl 
			x:Name="ContentElement" 
			BorderThickness="0" 
			Margin="{TemplateBinding Margin}"
			HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
			Padding="{TemplateBinding Padding}" 
			VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
	</ControlTemplate>

	<Style TargetType="local:ChatBubbleTextBox">
		<Setter Property="FontFamily" Value="{StaticResource FontFamilySegoeNormal}"/>
		<Setter Property="FontSize" Value="{StaticResource DefaultFontSizeMediumLarge}"/>
		<Setter Property="Background" Value="{StaticResource DefaultTextBoxBrush}"/>
		<Setter Property="Foreground" Value="{StaticResource DefaultTextBoxForegroundBrush}"/>
		<Setter Property="BorderBrush" Value="{StaticResource DefaultTextBoxBrush}"/>
		<Setter Property="SelectionBackground" Value="{StaticResource DefaultAccentBrush}"/>
		<Setter Property="SelectionForeground" Value="{StaticResource DefaultTextBoxSelectionForegroundBrush}"/>
		<Setter Property="BorderThickness" Value="{StaticResource DefaultBorderThickness}"/>
		<Setter Property="Padding" Value="6, 2"/>

		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="local:ChatBubbleTextBox">
					<Grid Background="Transparent">
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="CommonStates">
								<VisualState x:Name="Normal"/>
								<VisualState x:Name="MouseOver"/>
								<VisualState x:Name="Disabled">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="EnabledBorder">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Collapsed</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DisabledOrReadonlyBorder">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>

										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="LowerRightPath">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultDisabledBrush}"/>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="LowerLeftPath">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultDisabledBrush}"/>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="UpperRightPath">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultDisabledBrush}"/>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="UpperLeftPath">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultDisabledBrush}"/>
										</ObjectAnimationUsingKeyFrames>

									</Storyboard>
								</VisualState>
								<VisualState x:Name="ReadOnly">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="EnabledBorder">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Collapsed</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DisabledOrReadonlyBorder">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>

										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="DisabledOrReadonlyBorder">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultTextBoxBrush}"/>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="DisabledOrReadonlyBorder">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultTextBoxBrush}"/>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="DisabledOrReadonlyContent">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultTextBoxReadOnlyBrush}"/>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
							<VisualStateGroup x:Name="FocusStates">
								<VisualState x:Name="Focused">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="EnabledBorder">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultTextBoxEditBackgroundBrush}"/>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="EnabledBorder">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultTextBoxEditBorderBrush}"/>
										</ObjectAnimationUsingKeyFrames>

										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="LowerRightPath">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultTextBoxEditBorderBrush}"/>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="LowerLeftPath">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultTextBoxEditBorderBrush}"/>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="UpperRightPath">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultTextBoxEditBorderBrush}"/>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="UpperLeftPath">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultTextBoxEditBorderBrush}"/>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Unfocused"/>
							</VisualStateGroup>
							<VisualStateGroup x:Name="ChatBubbleDirectionStates">
								<VisualState x:Name="UpperRight">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="UpperRightPath">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="UpperLeft">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="UpperLeftPath">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="LowerRight">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="LowerRightPath">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="LowerLeft">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="LowerLeftPath">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>

						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
						</Grid.RowDefinitions>

						<Border 
							x:Name="EnabledBorder" 
							Grid.Row="1"
							Padding="{TemplateBinding Padding}"
							BorderThickness="{TemplateBinding BorderThickness}" 
							BorderBrush="{TemplateBinding BorderBrush}"
							Background="{TemplateBinding Background}">
							<Grid>
								<ContentControl
									x:Name="HintContentElement"
									BorderThickness="0" 
									Background="Transparent"
									Margin="{StaticResource DefaultTextBoxInnerMargin}"
									HorizontalContentAlignment="Stretch"
									VerticalContentAlignment="Stretch"
									Foreground="{StaticResource DefaultTextBoxReadOnlyBrush}"
									Content="{TemplateBinding Hint}" />
								<ContentControl 
									x:Name="ContentElement" 
									BorderThickness="0" 
									Background="Transparent"
									Margin="{StaticResource DefaultTextBoxInnerMargin}"
									HorizontalContentAlignment="Stretch"
									VerticalContentAlignment="Stretch" />
								
							</Grid>
						</Border>
						
						<Border 
							x:Name="DisabledOrReadonlyBorder" 
							Grid.Row="1"
							Padding="{TemplateBinding Padding}"	
							BorderThickness="{TemplateBinding BorderThickness}" 
							BorderBrush="{StaticResource DefaultDisabledBrush}" 
							Visibility="Collapsed">
							<TextBox 
								x:Name="DisabledOrReadonlyContent"
								Background="Transparent"
								Foreground="{StaticResource DefaultDisabledBrush}"
								IsReadOnly="True"
								HorizontalContentAlignment="Stretch"
								VerticalContentAlignment="Stretch"
								SelectionForeground="{TemplateBinding SelectionForeground}" 
								SelectionBackground="{TemplateBinding SelectionBackground}"
								TextAlignment="{TemplateBinding TextAlignment}" 
								TextWrapping="{TemplateBinding TextWrapping}" 
								Text="{TemplateBinding Text}" 
								Template="{StaticResource DisabledChatBubbleTextBoxTemplate}" />
						</Border>

						<Path 
							Name="LowerRightPath"
							Data="M0,0 L1,1 L1,0 "
							Grid.Row="2"
							Fill="{TemplateBinding BorderBrush}"
							Stretch="Fill"
							Margin="12,0"
							Height="12"
							Width="18"
							Visibility="Collapsed"
							HorizontalAlignment="Right" />
						<Path 
							Name="LowerLeftPath"
							Data="M0,0 L0,1 L1,0"
							Grid.Row="2"
							Fill="{TemplateBinding BorderBrush}"
							Stretch="Fill"
							Margin="12,0"
							Height="12"
							Width="18"
							Visibility="Collapsed"
							HorizontalAlignment="Left" />
						<Path 
							Name="UpperLeftPath"
							Data="M0,0 L1,1 L0,1 "
							Grid.Row="0"
							Fill="{TemplateBinding BorderBrush}"
							Stretch="Fill"
							Margin="12,0"
							Height="12"
							Width="18"
							Visibility="Collapsed"
							HorizontalAlignment="Left" />
						<Path 
							Name="UpperRightPath"
							Data="M0,1 L1,1 L1,0 "
							Grid.Row="0"
							Fill="{TemplateBinding BorderBrush}"
							Stretch="Fill"
							Margin="12,0"
							Height="12"
							Width="18"
							Visibility="Collapsed"
							HorizontalAlignment="Right" />

					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>